package video.others

class Complex(val real: Double, val imaginary: Double) {
    operator fun plus(other: Complex): Complex {
        return Complex(real + other.real, imaginary + other.imaginary)
    }

    operator fun invoke():Double{
        return Math.hypot(real,imaginary)
    }

    override fun toString(): String {
        return "$real + ${imaginary}i"
    }
}

fun main(args: Array<String>) {
    val complex1 = Complex(3.0, 4.0)
    val complex2 = Complex(2.0, 5.0)
    (complex1 + complex2).also(::println)
    println(complex1())
}